/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.qcoinpay;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.graphics.drawable.NinePatchDrawable;
import android.graphics.drawable.StateListDrawable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import com.qihoopp.framework.LogUtil;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public final class bi {
    private Context d;
    public static bi a;
    public static o b;
    public static Lock c;
    private static String e;
    private static int f;

    private bi(Context paramContext) {
        this.d = paramContext;
        paramContext = this;
        if (!(TextUtils.isEmpty(e)))
            return;
        DisplayMetrics localDisplayMetrics = new DisplayMetrics();
        ((Activity) paramContext.d).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
        switch (bi.f = localDisplayMetrics.densityDpi) {
        case 120:
            e = "icon-ldpi";
            return;
        case 160:
            e = "icon-mdpi";
            return;
        case 240:
            e = "icon";
            return;
        case 320:
            e = "icon-xdpi";
            return;
        }
        e = "icon";
    }

    public static bi a(Activity paramActivity) {
        if (a == null)
            c = new ReentrantLock();
        try {
            c.lock();
            if (a == null)
                a = new bi(paramActivity);
            c.unlock();
        } finally {
            c.unlock();
        }
        Object localObject = paramActivity = new q();
        long l = Runtime.getRuntime().maxMemory();
        ((q) localObject).a = Math.round(0.25F * (float) l);
        localObject = paramActivity;
        if (o.a == null)
            o.a = new o((q) localObject);
        b = o.a;
        return ((bi) a);
    }

    public final void a(ImageView paramImageView, String paramString) {
        try {
            paramImageView.setImageDrawable(a(paramString));
            return;
        } catch (Exception paramImageView) {
            LogUtil.e("LoadResource", "", paramImageView);
        }
    }

    public final void a(View paramView, String paramString) {
        try {
            paramView.setBackgroundDrawable(a(paramString));
            return;
        } catch (Exception paramView) {
            LogUtil.e("LoadResource", "--Exception--", paramView);
        }
    }

    public final Drawable a(String paramString) {
        if (b != null) {
            String str = paramString;
            o localo = b;
            Object localObject2 = null;
            if (localo.b != null)
                localObject2 = (Drawable) localo.b.c(str);
            if ((localObject1 = localObject2) != null)
                return ((Drawable) localObject1).getConstantState().newDrawable();
            Object localObject1 = a(this.d, paramString);
            localObject2 = localObject1;
            str = paramString;
            localo = b;
            if ((str != null) && (localObject2 != null))
                if (localo.b != null) {
                    if (s.class.isInstance(localObject2))
                        ((s) localObject2).a(true);
                    localo.b.a(str, localObject2);
                }
            return localObject1;
        }
        return ((Drawable) (Drawable) a(this.d, paramString));
    }

    public final void a(View paramView, String paramString1, String paramString2, String paramString3) {
        try {
            paramString1 = a(paramString1);
            paramString2 = a(paramString2);
            paramString3 = a(paramString3);
            StateListDrawable localStateListDrawable = new StateListDrawable();
            localStateListDrawable.addState(new int[] { 16842919, 16842910 }, paramString2);
            localStateListDrawable.addState(new int[] { 16842910, 16842908 }, paramString2);
            localStateListDrawable.addState(new int[] { 16842910 }, paramString1);
            localStateListDrawable.addState(new int[] { 16842908 }, paramString2);
            localStateListDrawable.addState(new int[0], paramString3);
            paramView.setBackgroundDrawable(localStateListDrawable);
            return;
        } catch (Exception paramString1) {
            LogUtil.e("LoadResource", "", paramString1);
        }
    }

    private static Drawable a(Context paramContext, String paramString) {
        if (TextUtils.isEmpty(paramString))
            return null;
        Bitmap localBitmap = b(paramString);
        if (paramString.contains(".9")) {
            paramString = localBitmap.getNinePatchChunk();
            Rect localRect1 = new Rect();
            Rect localRect2 = localRect1;
            String str = paramString;
            localRect2.left = a(str, 12);
            localRect2.right = a(str, 16);
            localRect2.top = a(str, 20);
            localRect2.bottom = a(str, 24);
            return new NinePatchDrawable(paramContext.getResources(), localBitmap, paramString, localRect1, null);
        }
        return new BitmapDrawable(paramContext.getResources(), localBitmap);
    }

    private static int a(byte[] paramArrayOfByte, int paramInt) {
        int i = paramArrayOfByte[(paramInt + 0)];
        int j = paramArrayOfByte[(paramInt + 1)];
        int k = paramArrayOfByte[(paramInt + 2)];
        paramArrayOfByte = paramArrayOfByte[(paramInt + 3)];
        return (i | j << 8 | k << 16 | paramArrayOfByte << 24);
    }

    private static Bitmap b(String paramString) {
        try {
            if (TextUtils.isEmpty(paramString))
                return null;
            BitmapFactory.Options localOptions;
            (localOptions = new BitmapFactory.Options()).inTargetDensity = f;
            localOptions.inDensity = 240;
            paramString = paramString.replace(".", "_");
            byte[] arrayOfByte = null;
            if (paramString.equals("bg_cover_9_png"))
                arrayOfByte = bj.a;
            else if (paramString.equals("bg_coverbtn_nor_png"))
                arrayOfByte = bk.a;
            else if (paramString.equals("bg_coverbtn_press_png"))
                arrayOfByte = bl.a;
            else if (paramString.equals("bg_dealinfo_png"))
                arrayOfByte = bm.a;
            else if (paramString.equals("bg_edt_9_png"))
                arrayOfByte = bn.a;
            else if (paramString.equals("bg_errornote_9_png"))
                arrayOfByte = bo.a;
            else if (paramString.equals("bg_paymode_nor_png"))
                arrayOfByte = bp.a;
            else if (paramString.equals("bg_paymode_press_png"))
                arrayOfByte = bq.a;
            else if (paramString.equals("bg_spriner_nor_9_png"))
                arrayOfByte = br.a;
            else if (paramString.equals("bg_spriner_press_9_png"))
                arrayOfByte = bs.a;
            else if (paramString.equals("bg_titlebar_png"))
                arrayOfByte = bt.a;
            else if (paramString.equals("bg_titlebtn_nor_9_png"))
                arrayOfByte = bu.a;
            else if (paramString.equals("bg_titlebtn_press_9_png"))
                arrayOfByte = bv.a;
            else if (paramString.equals("btn_nor_9_png"))
                arrayOfByte = bw.a;
            else if (paramString.equals("btn_press_9_png"))
                arrayOfByte = bx.a;
            else if (paramString.equals("img_360coin_png"))
                arrayOfByte = by.a;
            else if (paramString.equals("img_amount_nor_png"))
                arrayOfByte = bz.a;
            else if (paramString.equals("img_amount_press_png"))
                arrayOfByte = ca.a;
            else if (paramString.equals("img_arrow_png"))
                arrayOfByte = cb.a;
            else if (paramString.equals("img_close_png"))
                arrayOfByte = cc.a;
            else if (paramString.equals("img_dealshade_png"))
                arrayOfByte = cd.a;
            else if (paramString.equals("img_error_png"))
                arrayOfByte = ce.a;
            else if (paramString.equals("img_line_png"))
                arrayOfByte = cf.a;
            else if (paramString.equals("img_split_png"))
                arrayOfByte = cg.a;
            else if (paramString.equals("img_success_png"))
                arrayOfByte = ch.a;
            else if (paramString.equals("img_titleshade_png"))
                arrayOfByte = ci.a;
            else if (paramString.equals("loading1_png"))
                arrayOfByte = cm.a;
            else if (paramString.equals("loading2_png"))
                arrayOfByte = cn.a;
            else if (paramString.equals("loading3_png"))
                arrayOfByte = co.a;
            else if (paramString.equals("loading4_png"))
                arrayOfByte = cp.a;
            else if (paramString.equals("loading5_png"))
                arrayOfByte = cq.a;
            else if (paramString.equals("loading6_png"))
                arrayOfByte = cr.a;
            else if (paramString.equals("loading7_png"))
                arrayOfByte = cs.a;
            else if (paramString.equals("loading8_png"))
                arrayOfByte = ct.a;
            else if (paramString.equals("loading9_png"))
                arrayOfByte = cu.a;
            else if (paramString.equals("loading10_png"))
                arrayOfByte = cj.a;
            else if (paramString.equals("loading11_png"))
                arrayOfByte = ck.a;
            else if (paramString.equals("loading12_png"))
                arrayOfByte = cl.a;
            if (arrayOfByte == null)
                return null;
            return BitmapFactory.decodeByteArray(arrayOfByte, 0, arrayOfByte.length, localOptions);
        } catch (Exception localException) {
            localException.printStackTrace();
        }
        return null;
    }
}